package com.lily;

import org.junit.Test;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;

/**
 * @author lily
 */
public class testRedisByPool {
    @Test
    public void testString(){

        JedisPoolConfig config = new JedisPoolConfig();
        config.setMaxTotal(10);

        JedisPool jedisPool=new JedisPool("localhost",6379);//也可以指定
        Jedis jedis = jedisPool.getResource();
        //2.操作redis数据库
        jedis.set("name","yb");//set key value
        String name = jedis.get("name");//get key
        System.out.println(name);

        jedis.del("name");
        System.out.println(jedis.get("name"));
        //3.释放资源
        jedis.close();

    }
}
